package com.example.tms.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.tms.bean.*;
import com.example.tms.mapper.MoneyMapper;
import com.example.tms.mapper.OfficeMapper;
import com.example.tms.mapper.WaybillMapper;
import com.example.tms.tools.GlobalParam;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.util.*;
import com.example.tms.annotation.*;
/**
 * 运营分析
 */
@RestController
public class OperateController {

    private final WaybillMapper waybillMapper;
    private final MoneyMapper moneyMapper;
    private final OfficeMapper officeMapper;

    @Autowired
    public OperateController(WaybillMapper waybillMapper, MoneyMapper moneyMapper, OfficeMapper officeMapper) {
        this.waybillMapper = waybillMapper;
        this.moneyMapper = moneyMapper;
        this.officeMapper = officeMapper;
    }

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    //车辆费用统计
    @RequiresPermissions("312")
    @RequestMapping(value = "carcost", method = RequestMethod.GET)
    public ReturnInfo getCarCost(@RequestParam(required = false, defaultValue = "") String cph,
                                 @RequestParam(required = false, defaultValue = "") String qsrq,
                                 @RequestParam(required = false, defaultValue = "") String jsrq) {
        return ReturnInfo.info2(getCarCostList(cph, qsrq, jsrq));
    }

    //线路费用统计
    @RequiresPermissions("322")
    @RequestMapping(value = "roadcost", method = RequestMethod.GET)
    public ReturnInfo getRoadCost(@RequestParam(required = false, defaultValue = "") String xlmc,
                                  @RequestParam(required = false, defaultValue = "") String xlzjm,
                                  @RequestParam(required = false, defaultValue = "") String khjc,
                                  @RequestParam(required = false, defaultValue = "") String khzjm,
                                  @RequestParam(required = false, defaultValue = "") String qymc,
                                  @RequestParam(required = false, defaultValue = "") String qyzjm,
                                  @RequestParam(required = false, defaultValue = "") String qsrq,
                                  @RequestParam(required = false, defaultValue = "") String jsrq) {
        return ReturnInfo.info2(getRoadCostList(xlmc, xlzjm, khjc, khzjm, qymc, qyzjm, qsrq, jsrq));
    }

    //日期费用统计
    @RequiresPermissions("332")
    @RequestMapping(value = "datecost", method = RequestMethod.GET)
    public ReturnInfo getDateCost(@RequestParam(required = false, defaultValue = "") String qsrq,
                                  @RequestParam(required = false, defaultValue = "") String jsrq) {
        return ReturnInfo.info2(getDateCostList(qsrq, jsrq));
    }

    //车辆费用excel下载
    @RequiresPermissions("313")
    @RequestMapping(value = "/carexcel", method = RequestMethod.GET)
    public ReturnInfo getCarExcel(HttpServletResponse response, HttpServletRequest request) {
        String cph = "";
        String qsrq = "";
        String jsrq = "";
        if (request.getParameter("cph") != null) {
            cph = request.getParameter("cph");
        }
        if (request.getParameter("qsrq") != null) {
            qsrq = request.getParameter("qsrq");
        }
        if (request.getParameter("jsrq") != null) {
            jsrq = request.getParameter("jsrq");
        }
        String classPath = this.getClass().getClassLoader().getResource("").getPath();
        String path = classPath + "static/excel/";
        path = path.replaceAll("%20", " ");
        String filename = GlobalParam.getSSj() + ".xls";
        String newpath = path + filename;
        try {
            creatCarExcel(getCarCostList(cph, qsrq, jsrq), newpath, qsrq, jsrq);
        } catch (IOException e) {
            e.printStackTrace();
        }
        File newfile = new File(newpath);
        logger.info("车辆费用表" + filename + " 创建成功！");
        if (newfile.exists()) {
            response.setCharacterEncoding("UTF-8");
            response.setContentType("application/force-download");// 设置强制下载不打开
            response.addHeader("Content-Disposition",
                    "attachment;fileName=" + filename);// 设置文件名
            byte[] buffer = new byte[1024];
            FileInputStream fis = null;
            BufferedInputStream bis = null;
            try {
                fis = new FileInputStream(newfile);
                bis = new BufferedInputStream(fis);
                OutputStream os = response.getOutputStream();
                int i = bis.read(buffer);
                while (i != -1) {
                    os.write(buffer, 0, i);
                    i = bis.read(buffer);
                }
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (bis != null) {
                    try {
                        bis.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                if (fis != null) {
                    try {
                        fis.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        //文件删除
        if (newfile.delete()) {
            logger.info("车辆费用表" + filename + " 删除成功！");
        } else {
            logger.info("车辆费用表" + filename + " 删除失败！");
        }
        return null;
    }

    //线路费用excel下载
    @RequiresPermissions("323")
    @RequestMapping(value = "/roadexcel", method = RequestMethod.GET)
    public ReturnInfo getRoadExcel(HttpServletResponse response, HttpServletRequest request) {
        String xlmc = "";
        String xlzjm = "";
        String khjc = "";
        String khzjm = "";
        String qymc = "";
        String qyzjm = "";
        String qsrq = "";
        String jsrq = "";
        if (request.getParameter("xlmc") != null) {
            xlmc = request.getParameter("xlmc");
        }
        if (request.getParameter("xlzjm") != null) {
            xlzjm = request.getParameter("xlzjm");
        }
        if (request.getParameter("khjc") != null) {
            khjc = request.getParameter("khjc");
        }
        if (request.getParameter("khzjm") != null) {
            khzjm = request.getParameter("khzjm");
        }
        if (request.getParameter("qymc") != null) {
            qymc = request.getParameter("qymc");
        }
        if (request.getParameter("qyzjm") != null) {
            qyzjm = request.getParameter("qyzjm");
        }
        if (request.getParameter("qsrq") != null) {
            qsrq = request.getParameter("qsrq");
        }
        if (request.getParameter("jsrq") != null) {
            jsrq = request.getParameter("jsrq");
        }
        String classPath = this.getClass().getClassLoader().getResource("").getPath();
        String path = classPath + "static/excel/";
        String filename = GlobalParam.getSSj() + ".xls";
        String newpath = path + filename;
        try {
            creatRoadExcel(getRoadCostList(xlmc, xlzjm, khjc, khzjm, qymc, qyzjm, qsrq, jsrq), newpath, qsrq, jsrq);
        } catch (IOException e) {
            e.printStackTrace();
        }
        File newfile = new File(newpath);
        logger.info("线路费用表" + filename + " 创建成功！");
        if (newfile.exists()) {
            response.setCharacterEncoding("UTF-8");
            response.setContentType("application/force-download");// 设置强制下载不打开
            response.addHeader("Content-Disposition",
                    "attachment;fileName=" + filename);// 设置文件名
            byte[] buffer = new byte[1024];
            FileInputStream fis = null;
            BufferedInputStream bis = null;
            try {
                fis = new FileInputStream(newfile);
                bis = new BufferedInputStream(fis);
                OutputStream os = response.getOutputStream();
                int i = bis.read(buffer);
                while (i != -1) {
                    os.write(buffer, 0, i);
                    i = bis.read(buffer);
                }
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (bis != null) {
                    try {
                        bis.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                if (fis != null) {
                    try {
                        fis.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        //文件删除
        if (newfile.delete()) {
            logger.info("线路费用表" + filename + " 删除成功！");
        } else {
            logger.info("线路费用表" + filename + " 删除失败！");
        }
        return null;
    }

    //日期费用excel下载
    @RequiresPermissions("333")
    @RequestMapping(value = "/dateexcel", method = RequestMethod.GET)
    public ReturnInfo getDateExcel(HttpServletResponse response, HttpServletRequest request) {
        String qsrq = "";
        String jsrq = "";
        if (request.getParameter("qsrq") != null) {
            qsrq = request.getParameter("qsrq");
        }
        if (request.getParameter("jsrq") != null) {
            jsrq = request.getParameter("jsrq");
        }
        String classPath = this.getClass().getClassLoader().getResource("").getPath();
        String path = classPath + "static/excel/";
        String filename = GlobalParam.getSSj() + ".xls";
        String newpath = path + filename;
        try {
            creatDateExcel(getDateCostList(qsrq, jsrq), newpath, qsrq, jsrq);
        } catch (IOException e) {
            e.printStackTrace();
        }
        File newfile = new File(newpath);
        logger.info("日期费用表" + filename + " 创建成功！");
        if (newfile.exists()) {
            response.setCharacterEncoding("UTF-8");
            response.setContentType("application/force-download");// 设置强制下载不打开
            response.addHeader("Content-Disposition",
                    "attachment;fileName=" + filename);// 设置文件名
            byte[] buffer = new byte[1024];
            FileInputStream fis = null;
            BufferedInputStream bis = null;
            try {
                fis = new FileInputStream(newfile);
                bis = new BufferedInputStream(fis);
                OutputStream os = response.getOutputStream();
                int i = bis.read(buffer);
                while (i != -1) {
                    os.write(buffer, 0, i);
                    i = bis.read(buffer);
                }
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (bis != null) {
                    try {
                        bis.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                if (fis != null) {
                    try {
                        fis.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        //文件删除
        if (newfile.delete()) {
            logger.info("日期费用表" + filename + " 删除成功！");
        } else {
            logger.info("日期费用表" + filename + " 删除失败！");
        }
        return null;
    }

    private void creatCarExcel(List<CostInfo> costInfos, String newpath, String qsrq, String jsrq) throws IOException {
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFCellStyle cellStyle = wb.createCellStyle();
        cellStyle.setBorderBottom(BorderStyle.THIN);//下边框
        cellStyle.setBorderLeft(BorderStyle.THIN);//左边框
        cellStyle.setBorderTop(BorderStyle.THIN);//上边框
        cellStyle.setBorderRight(BorderStyle.THIN);//右边框
        cellStyle.setAlignment(HorizontalAlignment.CENTER);
        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
        HSSFSheet sheet = wb.createSheet("车辆费用统计表");
        sheet.setColumnWidth(0, 13 * 256);
        sheet.setColumnWidth(1, 13 * 256);
        sheet.setColumnWidth(2, 13 * 256);
        sheet.setColumnWidth(3, 13 * 256);
        sheet.setColumnWidth(5, 13 * 256);
        sheet.setColumnWidth(7, 13 * 256);
        sheet.setColumnWidth(8, 13 * 256);
        sheet.setColumnWidth(14, 16 * 256);
        sheet.setColumnWidth(15, 16 * 256);
        for (int x = 0; x < 4 + costInfos.size(); x++) {
            // 创建新建excel Sheet的行
            HSSFRow row = sheet.createRow(x);
            // 单元格式样
            for (int y = 0; y <= 30; y++) {
                row.createCell(y);
                row.getCell(y).setCellStyle(cellStyle);
            }
        }
        HSSFRow row1 = sheet.getRow(0);
        row1.setHeight((short) (25 * 20));
        row1.getCell(0).setCellValue("车辆费用统计表");
        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 30));
        HSSFRow row2 = sheet.getRow(1);
        row2.setHeight((short) (15 * 20));
        row2.getCell(0).setCellValue("统计日期：" + qsrq + "至" + jsrq);
        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 30));
        HSSFRow row3 = sheet.getRow(2);
        row3.setHeight((short) (25 * 20));
        row3.getCell(0).setCellValue("日期");
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 0, 0));
        row3.getCell(1).setCellValue("线路名称");
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 1, 1));
        row3.getCell(2).setCellValue("客户简称");
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 2, 2));
        row3.getCell(3).setCellValue("车牌号");
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 3, 3));
        row3.getCell(4).setCellValue("驾驶员");
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 4, 4));
        row3.getCell(5).setCellValue("驾驶员手机");
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 5, 5));
        row3.getCell(6).setCellValue("公里数");
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 6, 6));
        row3.getCell(7).setCellValue("理论充油金额");
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 7, 7));
        row3.getCell(8).setCellValue("实际充油金额");
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 8, 8));
        row3.getCell(9).setCellValue("支出项");
        sheet.addMergedRegion(new CellRangeAddress(2, 2, 9, 23));
        row3.getCell(24).setCellValue("收入项");
        sheet.addMergedRegion(new CellRangeAddress(2, 2, 24, 29));
        row3.getCell(30).setCellValue("利润");
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 30, 30));
        HSSFRow row4 = sheet.getRow(3);
        row4.setHeight((short) (20 * 20));
        row4.getCell(9).setCellValue("过路费");
        row4.getCell(10).setCellValue("节油");
        row4.getCell(11).setCellValue("现金加油");
        row4.getCell(12).setCellValue("线路补助");
        row4.getCell(13).setCellValue("买单");
        row4.getCell(14).setCellValue("维修费用（厂内）");
        row4.getCell(15).setCellValue("维修费用（厂外）");
        row4.getCell(16).setCellValue("违章罚款");
        row4.getCell(17).setCellValue("停车费");
        row4.getCell(18).setCellValue("住宿费");
        row4.getCell(19).setCellValue("装卸费");
        row4.getCell(20).setCellValue("船票");
        row4.getCell(21).setCellValue("事故处理");
        row4.getCell(22).setCellValue("配件");
        row4.getCell(23).setCellValue("其他支出");
        row4.getCell(24).setCellValue("超油");
        row4.getCell(25).setCellValue("回货");
        row4.getCell(26).setCellValue("回货补回");
        row4.getCell(27).setCellValue("油卡");
        row4.getCell(28).setCellValue("运费");
        row4.getCell(29).setCellValue("其他收入");
        JSONArray ja = JSONArray.parseArray(JSON.toJSONString(costInfos));
        int i = 4;
        for (Object aJa : ja) {
            JSONObject job = (JSONObject) aJa;
            HSSFRow row = sheet.getRow(i);
            row.setHeight((short) (20 * 20));
            row.getCell(0).setCellValue(job.get("fcrq").toString());
            row.getCell(1).setCellValue(job.get("xlmc").toString());
            row.getCell(2).setCellValue(job.get("khjc").toString());
            row.getCell(3).setCellValue(job.get("cph").toString());
            row.getCell(4).setCellValue(job.get("jsyxm").toString());
            row.getCell(5).setCellValue(job.get("jsysj").toString());
            row.getCell(6).setCellValue(job.get("gls").toString());
            row.getCell(7).setCellValue(job.get("llcyje").toString());
            row.getCell(8).setCellValue(job.get("sjcyje").toString());
            row.getCell(9).setCellValue(job.get("glf").toString());
            row.getCell(10).setCellValue(job.get("zcjy").toString());
            row.getCell(11).setCellValue(job.get("xjjy").toString());
            row.getCell(12).setCellValue(job.get("buzhu").toString());
            row.getCell(13).setCellValue(job.get("maidan").toString());
            row.getCell(14).setCellValue(job.get("wxfycn").toString());
            row.getCell(15).setCellValue(job.get("wxfycw").toString());
            row.getCell(16).setCellValue(job.get("wzfk").toString());
            row.getCell(17).setCellValue(job.get("tcf").toString());
            row.getCell(18).setCellValue(job.get("zsf").toString());
            row.getCell(19).setCellValue(job.get("zxf").toString());
            row.getCell(20).setCellValue(job.get("chuanpiao").toString());
            row.getCell(21).setCellValue(job.get("sgcl").toString());
            row.getCell(22).setCellValue(job.get("peijian").toString());
            row.getCell(23).setCellValue(job.get("zcqt").toString());
            row.getCell(24).setCellValue(job.get("srcy").toString());
            row.getCell(25).setCellValue(job.get("huihuo").toString());
            row.getCell(26).setCellValue(job.get("hhbh").toString());
            row.getCell(27).setCellValue(job.get("sryk").toString());
            row.getCell(28).setCellValue(job.get("sryf").toString());
            row.getCell(29).setCellValue(job.get("srqt").toString());
            row.getCell(30).setCellValue(job.get("lirun").toString());
            i++;
        }
        FileOutputStream out = new FileOutputStream(newpath);
        wb.write(out);
        out.close();
    }

    private void creatRoadExcel(List<CostInfo> costInfos, String newpath, String qsrq, String jsrq) throws IOException {
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFCellStyle cellStyle = wb.createCellStyle();
        cellStyle.setBorderBottom(BorderStyle.THIN);//下边框
        cellStyle.setBorderLeft(BorderStyle.THIN);//左边框
        cellStyle.setBorderTop(BorderStyle.THIN);//上边框
        cellStyle.setBorderRight(BorderStyle.THIN);//右边框
        cellStyle.setAlignment(HorizontalAlignment.CENTER);
        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
        HSSFSheet sheet = wb.createSheet("线路费用统计表");
        sheet.setColumnWidth(0, 13 * 256);
        sheet.setColumnWidth(1, 13 * 256);
        sheet.setColumnWidth(2, 13 * 256);
        sheet.setColumnWidth(8, 16 * 256);
        sheet.setColumnWidth(9, 16 * 256);
        for (int x = 0; x < 4 + costInfos.size(); x++) {
            // 创建新建excel Sheet的行
            HSSFRow row = sheet.createRow(x);
            // 单元格式样
            for (int y = 0; y <= 24; y++) {
                row.createCell(y);
                row.getCell(y).setCellStyle(cellStyle);
            }
        }
        HSSFRow row1 = sheet.getRow(0);
        row1.setHeight((short) (25 * 20));
        row1.getCell(0).setCellValue("线路费用统计表");
        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 24));
        HSSFRow row2 = sheet.getRow(1);
        row2.setHeight((short) (15 * 20));
        row2.getCell(0).setCellValue("统计日期：" + qsrq + "至" + jsrq);
        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 24));
        HSSFRow row3 = sheet.getRow(2);
        row3.getCell(0).setCellValue("线路名称");
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 0, 0));
        row3.getCell(1).setCellValue("理论充油金额");
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 1, 1));
        row3.getCell(2).setCellValue("实际充油金额");
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 2, 2));
        row3.getCell(3).setCellValue("支出项");
        sheet.addMergedRegion(new CellRangeAddress(2, 2, 3, 17));
        row3.getCell(18).setCellValue("收入项");
        sheet.addMergedRegion(new CellRangeAddress(2, 2, 18, 23));
        row3.getCell(24).setCellValue("利润");
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 24, 24));
        HSSFRow row4 = sheet.getRow(3);
        row4.getCell(3).setCellValue("过路费");
        row4.getCell(4).setCellValue("节油");
        row4.getCell(5).setCellValue("现金加油");
        row4.getCell(6).setCellValue("线路补助");
        row4.getCell(7).setCellValue("买单");
        row4.getCell(8).setCellValue("维修费用（厂内）");
        row4.getCell(9).setCellValue("维修费用（厂外）");
        row4.getCell(10).setCellValue("违章罚款");
        row4.getCell(11).setCellValue("停车费");
        row4.getCell(12).setCellValue("住宿费");
        row4.getCell(13).setCellValue("装卸费");
        row4.getCell(14).setCellValue("船票");
        row4.getCell(15).setCellValue("事故处理");
        row4.getCell(16).setCellValue("配件");
        row4.getCell(17).setCellValue("其他支出");
        row4.getCell(18).setCellValue("超油");
        row4.getCell(19).setCellValue("回货");
        row4.getCell(20).setCellValue("回货补回");
        row4.getCell(21).setCellValue("油卡");
        row4.getCell(22).setCellValue("运费");
        row4.getCell(23).setCellValue("其他收入");
        JSONArray ja = JSONArray.parseArray(JSON.toJSONString(costInfos));
        int i = 4;
        for (Object aJa : ja) {
            JSONObject job = (JSONObject) aJa;
            HSSFRow row = sheet.getRow(i);
            row.setHeight((short) (20 * 20));
            row.getCell(0).setCellValue(job.get("xlmc").toString());
            row.getCell(1).setCellValue(job.get("llcyje").toString());
            row.getCell(2).setCellValue(job.get("sjcyje").toString());
            row.getCell(3).setCellValue(job.get("glf").toString());
            row.getCell(4).setCellValue(job.get("zcjy").toString());
            row.getCell(5).setCellValue(job.get("xjjy").toString());
            row.getCell(6).setCellValue(job.get("buzhu").toString());
            row.getCell(7).setCellValue(job.get("maidan").toString());
            row.getCell(8).setCellValue(job.get("wxfycn").toString());
            row.getCell(9).setCellValue(job.get("wxfycw").toString());
            row.getCell(10).setCellValue(job.get("wzfk").toString());
            row.getCell(11).setCellValue(job.get("tcf").toString());
            row.getCell(12).setCellValue(job.get("zsf").toString());
            row.getCell(13).setCellValue(job.get("zxf").toString());
            row.getCell(14).setCellValue(job.get("chuanpiao").toString());
            row.getCell(15).setCellValue(job.get("sgcl").toString());
            row.getCell(16).setCellValue(job.get("peijian").toString());
            row.getCell(17).setCellValue(job.get("zcqt").toString());
            row.getCell(18).setCellValue(job.get("srcy").toString());
            row.getCell(19).setCellValue(job.get("huihuo").toString());
            row.getCell(20).setCellValue(job.get("hhbh").toString());
            row.getCell(21).setCellValue(job.get("sryk").toString());
            row.getCell(22).setCellValue(job.get("sryf").toString());
            row.getCell(23).setCellValue(job.get("srqt").toString());
            row.getCell(24).setCellValue(job.get("lirun").toString());
            i++;
        }
        FileOutputStream out = new FileOutputStream(newpath);
        wb.write(out);
        out.close();
    }

    private void creatDateExcel(List<CostInfo> costInfos, String newpath, String qsrq, String jsrq) throws IOException {
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFCellStyle cellStyle = wb.createCellStyle();
        cellStyle.setBorderBottom(BorderStyle.THIN);//下边框
        cellStyle.setBorderLeft(BorderStyle.THIN);//左边框
        cellStyle.setBorderTop(BorderStyle.THIN);//上边框
        cellStyle.setBorderRight(BorderStyle.THIN);//右边框
        cellStyle.setAlignment(HorizontalAlignment.CENTER);
        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
        HSSFSheet sheet = wb.createSheet("日期费用统计表");
        sheet.setColumnWidth(0, 13 * 256);
        sheet.setColumnWidth(6, 16 * 256);
        sheet.setColumnWidth(7, 16 * 256);
        sheet.setColumnWidth(16, 13 * 256);
        sheet.setColumnWidth(22, 13 * 256);
        for (int x = 0; x < 4 + costInfos.size(); x++) {
            // 创建新建excel Sheet的行
            HSSFRow row = sheet.createRow(x);
            // 单元格式样
            for (int y = 0; y <= 26; y++) {
                row.createCell(y);
                row.getCell(y).setCellStyle(cellStyle);
            }
        }
        HSSFRow row1 = sheet.getRow(0);
        row1.setHeight((short) (25 * 20));
        row1.getCell(0).setCellValue("日期费用统计表");
        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 26));
        HSSFRow row2 = sheet.getRow(1);
        row2.setHeight((short) (15 * 20));
        row2.getCell(0).setCellValue("统计日期：" + qsrq + "至" + jsrq);
        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 26));
        HSSFRow row3 = sheet.getRow(2);
        row3.getCell(0).setCellValue("报账日期");
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 0, 0));
        row3.getCell(1).setCellValue("支出项");
        sheet.addMergedRegion(new CellRangeAddress(2, 2, 1, 17));
        row3.getCell(18).setCellValue("收入项");
        sheet.addMergedRegion(new CellRangeAddress(2, 2, 18, 25));
        row3.getCell(24).setCellValue("当日余额");
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 26, 26));
        HSSFRow row4 = sheet.getRow(3);
        row4.getCell(1).setCellValue("过路费");
        row4.getCell(2).setCellValue("节油");
        row4.getCell(3).setCellValue("现金加油");
        row4.getCell(4).setCellValue("线路补助");
        row4.getCell(5).setCellValue("买单");
        row4.getCell(6).setCellValue("维修费用（厂内）");
        row4.getCell(7).setCellValue("维修费用（厂外）");
        row4.getCell(8).setCellValue("违章罚款");
        row4.getCell(9).setCellValue("停车费");
        row4.getCell(10).setCellValue("住宿费");
        row4.getCell(11).setCellValue("装卸费");
        row4.getCell(12).setCellValue("船票");
        row4.getCell(13).setCellValue("事故处理");
        row4.getCell(14).setCellValue("配件");
        row4.getCell(15).setCellValue("其他支出");
        row4.getCell(16).setCellValue("办公室支出");
        row4.getCell(17).setCellValue("当日借款");
        row4.getCell(18).setCellValue("超油");
        row4.getCell(19).setCellValue("回货");
        row4.getCell(20).setCellValue("回货补回");
        row4.getCell(21).setCellValue("其他收入");
        row4.getCell(22).setCellValue("办公室收入");
        row4.getCell(23).setCellValue("当日取款");
        row4.getCell(24).setCellValue("当日还款");
        row4.getCell(25).setCellValue("昨日余额");
        JSONArray ja = JSONArray.parseArray(JSON.toJSONString(costInfos));
        int i = 4;
        for (Object aJa : ja) {
            JSONObject job = (JSONObject) aJa;
            HSSFRow row = sheet.getRow(i);
            row.setHeight((short) (20 * 20));
            row.getCell(0).setCellValue(job.get("bzrq").toString());
            row.getCell(1).setCellValue(job.get("glf").toString());
            row.getCell(2).setCellValue(job.get("zcjy").toString());
            row.getCell(3).setCellValue(job.get("xjjy").toString());
            row.getCell(4).setCellValue(job.get("buzhu").toString());
            row.getCell(5).setCellValue(job.get("maidan").toString());
            row.getCell(6).setCellValue(job.get("wxfycn").toString());
            row.getCell(7).setCellValue(job.get("wxfycw").toString());
            row.getCell(8).setCellValue(job.get("wzfk").toString());
            row.getCell(9).setCellValue(job.get("tcf").toString());
            row.getCell(10).setCellValue(job.get("zsf").toString());
            row.getCell(11).setCellValue(job.get("zxf").toString());
            row.getCell(12).setCellValue(job.get("chuanpiao").toString());
            row.getCell(13).setCellValue(job.get("sgcl").toString());
            row.getCell(14).setCellValue(job.get("peijian").toString());
            row.getCell(15).setCellValue(job.get("zcqt").toString());
            row.getCell(16).setCellValue(job.get("bgszc").toString());
            row.getCell(17).setCellValue(job.get("drjk").toString());
            row.getCell(18).setCellValue(job.get("srcy").toString());
            row.getCell(19).setCellValue(job.get("huihuo").toString());
            row.getCell(20).setCellValue(job.get("hhbh").toString());
            row.getCell(21).setCellValue(job.get("srqt").toString());
            row.getCell(22).setCellValue(job.get("bgssr").toString());
            row.getCell(23).setCellValue(job.get("drqk").toString());
            row.getCell(24).setCellValue(job.get("drhk").toString());
            row.getCell(25).setCellValue(job.get("zrye").toString());
            row.getCell(26).setCellValue(job.get("drye").toString());
            i++;
        }
        FileOutputStream out = new FileOutputStream(newpath);
        wb.write(out);
        out.close();
    }

    private List<CostInfo> getCarCostList(String cph, String qsrq, String jsrq) {
        List<WaybillMgmt> result = waybillMapper.findAll((Root<WaybillMgmt> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) -> {
            List<Predicate> list = new ArrayList<>();
            if (!cph.equals("")) {
                list.add(criteriaBuilder.like(root.get("cph").as(String.class), "%" + cph + "%"));
            }
            if (!qsrq.equals("")) {
                list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("fcrq").as(String.class), qsrq));
            }
            if (!jsrq.equals("")) {
                list.add(criteriaBuilder.lessThanOrEqualTo(root.get("fcrq").as(String.class), jsrq));
            }
            list.add(criteriaBuilder.equal(root.get("sfcz").as(Boolean.class), true));
            Predicate[] p = new Predicate[list.size()];
            criteriaQuery.where(criteriaBuilder.and(list.toArray(p)));
            return criteriaQuery.getRestriction();
        });
        Map<String, String[]> maps = new HashMap<>();
        JSONArray ja = JSONArray.parseArray(JSON.toJSONString(result));
        for (Object aJa : ja) {
            JSONObject job = (JSONObject) aJa;
            String cp = "";
            String fcrq = "";
            String xlmc = "";
            String jsyxm = "";
            String jsysj = "";
            String khjc = "";
            if (job.containsKey("cph") && !job.get("cph").toString().equals("")) {
                cp = job.get("cph").toString();
            }
            if (job.containsKey("fcrq") && !job.get("fcrq").toString().equals("")) {
                fcrq = job.get("fcrq").toString();
            }
            if (job.containsKey("xlmc") && !job.get("xlmc").toString().equals("")) {
                xlmc = job.get("xlmc").toString();
            }
            if (job.containsKey("khjc") && !job.get("khjc").toString().equals("")) {
                khjc = job.get("khjc").toString();
            }
            if (job.containsKey("jsyxm") && !job.get("jsyxm").toString().equals("")) {
                jsyxm = job.get("jsyxm").toString();
            }
            if (job.containsKey("jsysj") && !job.get("jsysj").toString().equals("")) {
                jsysj = job.get("jsysj").toString();
            }
            String key = cp + "," + fcrq + "," + xlmc + "," + jsyxm + "," + jsysj + "," + khjc;
            //判断值是否为空字符串，是的话设为0
            String c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24;
            if (!job.get("gls").toString().equals("") && job.get("gls").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c1 = job.get("gls").toString();
            } else {
                c1 = "0.00";
            }
            if (!job.get("llcyje").toString().equals("") && job.get("llcyje").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c2 = job.get("llcyje").toString();
            } else {
                c2 = "0.00";
            }
            if (!job.get("sjcyje").toString().equals("") && job.get("sjcyje").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c3 = job.get("sjcyje").toString();
            } else {
                c3 = "0.00";
            }
            if (!job.get("glf").toString().equals("") && job.get("glf").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c4 = job.get("glf").toString();
            } else {
                c4 = "0.00";
            }
            if (!job.get("zcjy").toString().equals("") && job.get("zcjy").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c5 = job.get("zcjy").toString();
            } else {
                c5 = "0.00";
            }
            if (!job.get("xjjy").toString().equals("") && job.get("xjjy").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c6 = job.get("xjjy").toString();
            } else {
                c6 = "0.00";
            }
            if (!job.get("buzhu").toString().equals("") && job.get("buzhu").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c7 = job.get("buzhu").toString();
            } else {
                c7 = "0.00";
            }
            if (!job.get("maidan").toString().equals("") && job.get("maidan").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c8 = job.get("maidan").toString();
            } else {
                c8 = "0.00";
            }
            if (!job.get("wxfycn").toString().equals("") && job.get("wxfycn").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c9 = job.get("wxfycn").toString();
            } else {
                c9 = "0.00";
            }
            if (!job.get("wxfycw").toString().equals("") && job.get("wxfycw").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c10 = job.get("wxfycw").toString();
            } else {
                c10 = "0.00";
            }
            if (!job.get("wzfk").toString().equals("") && job.get("wzfk").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c11 = job.get("wzfk").toString();
            } else {
                c11 = "0.00";
            }
            if (!job.get("tcf").toString().equals("") && job.get("tcf").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c12 = job.get("tcf").toString();
            } else {
                c12 = "0.00";
            }
            if (!job.get("zsf").toString().equals("") && job.get("zsf").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c13 = job.get("zsf").toString();
            } else {
                c13 = "0.00";
            }
            if (!job.get("zxf").toString().equals("") && job.get("zxf").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c14 = job.get("zxf").toString();
            } else {
                c14 = "0.00";
            }
            if (!job.get("chuanpiao").toString().equals("") && job.get("chuanpiao").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c15 = job.get("chuanpiao").toString();
            } else {
                c15 = "0.00";
            }
            if (!job.get("sgcl").toString().equals("") && job.get("sgcl").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c16 = job.get("sgcl").toString();
            } else {
                c16 = "0.00";
            }
            if (!job.get("peijian").toString().equals("") && job.get("peijian").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c17 = job.get("peijian").toString();
            } else {
                c17 = "0.00";
            }
            if (!job.get("zcqt").toString().equals("") && job.get("zcqt").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c18 = job.get("zcqt").toString();
            } else {
                c18 = "0.00";
            }
            if (!job.get("srcy").toString().equals("") && job.get("srcy").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c19 = job.get("srcy").toString();
            } else {
                c19 = "0.00";
            }
            if (!job.get("huihuo").toString().equals("") && job.get("huihuo").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c20 = job.get("huihuo").toString();
            } else {
                c20 = "0.00";
            }
            if (!job.get("hhbh").toString().equals("") && job.get("hhbh").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c21 = job.get("hhbh").toString();
            } else {
                c21 = "0.00";
            }
            if (!job.get("sryk").toString().equals("") && job.get("sryk").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c22 = job.get("sryk").toString();
            } else {
                c22 = "0.00";
            }
            if (!job.get("sryf").toString().equals("") && job.get("sryf").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c23 = job.get("sryf").toString();
            } else {
                c23 = "0.00";
            }
            if (!job.get("srqt").toString().equals("") && job.get("srqt").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c24 = job.get("srqt").toString();
            } else {
                c24 = "0.00";
            }
            if (!maps.containsKey(key)) {
                String value[] = {c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24};
                maps.put(key, value);
            } else {
                String[] val = maps.get(key);
                val[0] = Add(val[0], c1);
                val[1] = Add(val[1], c2);
                val[2] = Add(val[2], c3);
                val[3] = Add(val[3], c4);
                val[4] = Add(val[4], c5);
                val[5] = Add(val[5], c6);
                val[6] = Add(val[6], c7);
                val[7] = Add(val[7], c8);
                val[8] = Add(val[8], c9);
                val[9] = Add(val[9], c10);
                val[10] = Add(val[10], c11);
                val[11] = Add(val[11], c12);
                val[12] = Add(val[12], c13);
                val[13] = Add(val[13], c14);
                val[14] = Add(val[14], c15);
                val[15] = Add(val[15], c16);
                val[16] = Add(val[16], c17);
                val[17] = Add(val[17], c18);
                val[18] = Add(val[18], c19);
                val[19] = Add(val[19], c20);
                val[20] = Add(val[20], c21);
                val[21] = Add(val[21], c22);
                val[22] = Add(val[22], c23);
                val[23] = Add(val[23], c24);
                maps.put(key, val);
            }
        }
        List<CostInfo> costInfos = new ArrayList<>();
        for (Map.Entry<String, String[]> entry : maps.entrySet()) {
            System.out.println("key:" + entry.getKey());
            String keys[] = entry.getKey().split(",", 6);
            String values[] = entry.getValue();
            costInfos.add(new CostInfo(keys, values));
        }
        return costInfos;
    }

    private List<CostInfo> getRoadCostList(String xlmc, String xlzjm, String khjc, String khzjm, String qymc, String qyzjm, String qsrq, String jsrq) {
        List<WaybillMgmt> result = waybillMapper.findAll((Root<WaybillMgmt> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) -> {
            List<Predicate> list = new ArrayList<>();
            if (!xlmc.equals("")) {
                list.add(criteriaBuilder.like(root.get("xlmc").as(String.class), "%" + xlmc + "%"));
            }
            if (!xlzjm.equals("")) {
                list.add(criteriaBuilder.like(root.get("xlzjm").as(String.class), "%" + xlzjm + "%"));
            }
            if (!khjc.equals("")) {
                list.add(criteriaBuilder.like(root.get("khjc").as(String.class), "%" + khjc + "%"));
            }
            if (!khzjm.equals("")) {
                list.add(criteriaBuilder.like(root.get("khzjm").as(String.class), "%" + khzjm + "%"));
            }
            if (!qymc.equals("")) {
                list.add(criteriaBuilder.like(root.get("cph").as(String.class), "%" + qymc + "%"));
            }
            if (!qyzjm.equals("")) {
                list.add(criteriaBuilder.like(root.get("zjm").as(String.class), "%" + qyzjm + "%"));
            }
            if (!qsrq.equals("")) {
                list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("bzrq").as(String.class), qsrq));
            }
            if (!jsrq.equals("")) {
                list.add(criteriaBuilder.lessThanOrEqualTo(root.get("bzrq").as(String.class), jsrq));
            }
            list.add(criteriaBuilder.equal(root.get("sfcz").as(Boolean.class), true));
            Predicate[] p = new Predicate[list.size()];
            criteriaQuery.where(criteriaBuilder.and(list.toArray(p)));
            return criteriaQuery.getRestriction();
        });
        Map<String, String[]> maps = new HashMap<>();
        JSONArray ja = JSONArray.parseArray(JSON.toJSONString(result));
        for (Object aJa : ja) {
            JSONObject job = (JSONObject) aJa;
            String key = job.get("xlmc").toString();
            //判断值是否为空字符串，是的话设为0
            String c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24;
            if (!job.get("llcyje").toString().equals("") && job.get("llcyje").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c2 = job.get("llcyje").toString();
            } else {
                c2 = "0.00";
            }
            if (!job.get("sjcyje").toString().equals("") && job.get("sjcyje").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c3 = job.get("sjcyje").toString();
            } else {
                c3 = "0.00";
            }
            if (!job.get("glf").toString().equals("") && job.get("glf").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c4 = job.get("glf").toString();
            } else {
                c4 = "0.00";
            }
            if (!job.get("zcjy").toString().equals("") && job.get("zcjy").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c5 = job.get("zcjy").toString();
            } else {
                c5 = "0.00";
            }
            if (!job.get("xjjy").toString().equals("") && job.get("xjjy").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c6 = job.get("xjjy").toString();
            } else {
                c6 = "0.00";
            }
            if (!job.get("buzhu").toString().equals("") && job.get("buzhu").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c7 = job.get("buzhu").toString();
            } else {
                c7 = "0.00";
            }
            if (!job.get("maidan").toString().equals("") && job.get("maidan").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c8 = job.get("maidan").toString();
            } else {
                c8 = "0.00";
            }
            if (!job.get("wxfycn").toString().equals("") && job.get("wxfycn").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c9 = job.get("wxfycn").toString();
            } else {
                c9 = "0.00";
            }
            if (!job.get("wxfycw").toString().equals("") && job.get("wxfycw").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c10 = job.get("wxfycw").toString();
            } else {
                c10 = "0.00";
            }
            if (!job.get("wzfk").toString().equals("") && job.get("wzfk").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c11 = job.get("wzfk").toString();
            } else {
                c11 = "0.00";
            }
            if (!job.get("tcf").toString().equals("") && job.get("tcf").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c12 = job.get("tcf").toString();
            } else {
                c12 = "0.00";
            }
            if (!job.get("zsf").toString().equals("") && job.get("zsf").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c13 = job.get("zsf").toString();
            } else {
                c13 = "0.00";
            }
            if (!job.get("zxf").toString().equals("") && job.get("zxf").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c14 = job.get("zxf").toString();
            } else {
                c14 = "0.00";
            }
            if (!job.get("chuanpiao").toString().equals("") && job.get("chuanpiao").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c15 = job.get("chuanpiao").toString();
            } else {
                c15 = "0.00";
            }
            if (!job.get("sgcl").toString().equals("") && job.get("sgcl").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c16 = job.get("sgcl").toString();
            } else {
                c16 = "0.00";
            }
            if (!job.get("peijian").toString().equals("") && job.get("peijian").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c17 = job.get("peijian").toString();
            } else {
                c17 = "0.00";
            }
            if (!job.get("zcqt").toString().equals("") && job.get("zcqt").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c18 = job.get("zcqt").toString();
            } else {
                c18 = "0.00";
            }
            if (!job.get("srcy").toString().equals("") && job.get("srcy").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c19 = job.get("srcy").toString();
            } else {
                c19 = "0.00";
            }
            if (!job.get("huihuo").toString().equals("") && job.get("huihuo").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c20 = job.get("huihuo").toString();
            } else {
                c20 = "0.00";
            }
            if (!job.get("hhbh").toString().equals("") && job.get("hhbh").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c21 = job.get("hhbh").toString();
            } else {
                c21 = "0.00";
            }
            if (!job.get("sryk").toString().equals("") && job.get("sryk").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c22 = job.get("sryk").toString();
            } else {
                c22 = "0.00";
            }
            if (!job.get("sryf").toString().equals("") && job.get("sryf").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c23 = job.get("sryf").toString();
            } else {
                c23 = "0.00";
            }
            if (!job.get("srqt").toString().equals("") && job.get("srqt").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c24 = job.get("srqt").toString();
            } else {
                c24 = "0.00";
            }
            if (!maps.containsKey(key)) {
                String value[] = {"0", c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24};
                maps.put(key, value);
            } else {
                String[] val = maps.get(key);
                val[0] = "0";
                val[1] = Add(val[1], c2);
                val[2] = Add(val[2], c3);
                val[3] = Add(val[3], c4);
                val[4] = Add(val[4], c5);
                val[5] = Add(val[5], c6);
                val[6] = Add(val[6], c7);
                val[7] = Add(val[7], c8);
                val[8] = Add(val[8], c9);
                val[9] = Add(val[9], c10);
                val[10] = Add(val[10], c11);
                val[11] = Add(val[11], c12);
                val[12] = Add(val[12], c13);
                val[13] = Add(val[13], c14);
                val[14] = Add(val[14], c15);
                val[15] = Add(val[15], c16);
                val[16] = Add(val[16], c17);
                val[17] = Add(val[17], c18);
                val[18] = Add(val[18], c19);
                val[19] = Add(val[19], c20);
                val[20] = Add(val[20], c21);
                val[21] = Add(val[21], c22);
                val[22] = Add(val[22], c23);
                val[23] = Add(val[23], c24);
                maps.put(key, val);
            }
        }
        List<CostInfo> costInfos = new ArrayList<>();
        for (Map.Entry<String, String[]> entry : maps.entrySet()) {
            String keys = entry.getKey();
            String values[] = entry.getValue();
            costInfos.add(new CostInfo(keys, values));
        }
        return costInfos;
    }

    private List<CostInfo> getDateCostList(String qsrq, String jsrq) {
        List<WaybillMgmt> result = waybillMapper.findAll((Root<WaybillMgmt> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) -> {
            List<Predicate> list = new ArrayList<>();
            if (!qsrq.equals("")) {
                list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("bzrq").as(String.class), qsrq));
            }
            if (!jsrq.equals("")) {
                list.add(criteriaBuilder.lessThanOrEqualTo(root.get("bzrq").as(String.class), jsrq));
            }
            list.add(criteriaBuilder.equal(root.get("sfcz").as(Boolean.class), true));
            Predicate[] p = new Predicate[list.size()];
            criteriaQuery.where(criteriaBuilder.and(list.toArray(p)));
            criteriaQuery.orderBy(criteriaBuilder.asc(root.get("bzrq")));
            return criteriaQuery.getRestriction();
        });
        Map<String, String[]> maps = new LinkedHashMap<String, String[]>();
        JSONArray ja = JSONArray.parseArray(JSON.toJSONString(result));
        for (Object aJa : ja) {
            JSONObject job = (JSONObject) aJa;
            String key = job.get("bzrq").toString();
            //判断值是否为空字符串，是的话设为0
            String c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19;
            if (!job.get("glf").toString().equals("") && job.get("glf").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c1 = job.get("glf").toString();
            } else {
                c1 = "0.00";
            }
            if (!job.get("zcjy").toString().equals("") && job.get("zcjy").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c2 = job.get("zcjy").toString();
            } else {
                c2 = "0.00";
            }
            if (!job.get("xjjy").toString().equals("") && job.get("xjjy").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c3 = job.get("xjjy").toString();
            } else {
                c3 = "0.00";
            }
            if (!job.get("buzhu").toString().equals("") && job.get("buzhu").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c4 = job.get("buzhu").toString();
            } else {
                c4 = "0.00";
            }
            if (!job.get("maidan").toString().equals("") && job.get("maidan").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c5 = job.get("maidan").toString();
            } else {
                c5 = "0.00";
            }
            if (!job.get("wxfycn").toString().equals("") && job.get("wxfycn").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c6 = job.get("wxfycn").toString();
            } else {
                c6 = "0.00";
            }
            if (!job.get("wxfycw").toString().equals("") && job.get("wxfycw").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c7 = job.get("wxfycw").toString();
            } else {
                c7 = "0.00";
            }
            if (!job.get("wzfk").toString().equals("") && job.get("wzfk").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c8 = job.get("wzfk").toString();
            } else {
                c8 = "0.00";
            }
            if (!job.get("tcf").toString().equals("") && job.get("tcf").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c9 = job.get("tcf").toString();
            } else {
                c9 = "0.00";
            }
            if (!job.get("zsf").toString().equals("") && job.get("zsf").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c10 = job.get("zsf").toString();
            } else {
                c10 = "0.00";
            }
            if (!job.get("zxf").toString().equals("") && job.get("zxf").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c11 = job.get("zxf").toString();
            } else {
                c11 = "0.00";
            }
            if (!job.get("chuanpiao").toString().equals("") && job.get("chuanpiao").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c12 = job.get("chuanpiao").toString();
            } else {
                c12 = "0.00";
            }
            if (!job.get("sgcl").toString().equals("") && job.get("sgcl").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c13 = job.get("sgcl").toString();
            } else {
                c13 = "0.00";
            }
            if (!job.get("peijian").toString().equals("") && job.get("peijian").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c14 = job.get("peijian").toString();
            } else {
                c14 = "0.00";
            }
            if (!job.get("zcqt").toString().equals("") && job.get("zcqt").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c15 = job.get("zcqt").toString();
            } else {
                c15 = "0.00";
            }
            if (!job.get("srcy").toString().equals("") && job.get("srcy").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c16 = job.get("srcy").toString();
            } else {
                c16 = "0.00";
            }
            if (!job.get("huihuo").toString().equals("") && job.get("huihuo").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c17 = job.get("huihuo").toString();
            } else {
                c17 = "0.00";
            }
            if (!job.get("hhbh").toString().equals("") && job.get("hhbh").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c18 = job.get("hhbh").toString();
            } else {
                c18 = "0.00";
            }
            if (!job.get("srqt").toString().equals("") && job.get("srqt").toString().matches("^([1-9]\\d*(\\.\\d*[1-9])?)|(0\\.\\d*[1-9])$")) {
                c19 = job.get("srqt").toString();
            } else {
                c19 = "0.00";
            }
            if (!maps.containsKey(key)) {
                String value[] = {c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19};
                maps.put(key, value);
            } else {
                String[] val = maps.get(key);
                val[0] = Add(val[0], c1);
                val[1] = Add(val[1], c2);
                val[2] = Add(val[2], c3);
                val[3] = Add(val[3], c4);
                val[4] = Add(val[4], c5);
                val[5] = Add(val[5], c6);
                val[6] = Add(val[6], c7);
                val[7] = Add(val[7], c8);
                val[8] = Add(val[8], c9);
                val[9] = Add(val[9], c10);
                val[10] = Add(val[10], c11);
                val[11] = Add(val[11], c12);
                val[12] = Add(val[12], c13);
                val[13] = Add(val[13], c14);
                val[14] = Add(val[14], c15);
                val[15] = Add(val[15], c16);
                val[16] = Add(val[16], c17);
                val[17] = Add(val[17], c18);
                val[18] = Add(val[18], c19);
                maps.put(key, val);
            }
        }


        List<CostInfo> costInfos = new ArrayList<>();
        for (Map.Entry<String, String[]> entry : maps.entrySet()) {
            String keys = entry.getKey();
            List<MoneyInfo> moneyInfos = moneyMapper.findByRiqiAndSfcz(keys, true);
            String drjk = "0", drqk = "0", drhk = "0", zrye = "0";
            for (MoneyInfo moneyInfo : moneyInfos) {
                switch (moneyInfo.getMingmu()) {
                    case "当日借款":
                        drjk = Add(drjk, moneyInfo.getJine());
                        break;
                    case "当日取款":
                        drqk = Add(drqk, moneyInfo.getJine());
                        break;
                    case "当日还款":
                        drhk = Add(drhk, moneyInfo.getJine());
                        break;
                    case "昨日余额":
                        zrye = Add(zrye, moneyInfo.getJine());
                        break;
                }
            }
            List<OfficeInfo> officeInfos = officeMapper.findByRiqiAndSfcz(keys, true);
            String bgssr = "0", bgszc = "0";
            for (OfficeInfo officeInfo : officeInfos) {
                if (checkNegative(officeInfo.getJine())) {
                    bgszc = Add(bgszc, Absolute(officeInfo.getJine()));
                } else {
                    bgssr = Add(bgssr, officeInfo.getJine());
                }
            }
            String values[] = entry.getValue();
            costInfos.add(new CostInfo(keys, values, drjk, drqk, drhk, zrye, bgssr, bgszc));
        }
        return costInfos;
    }

    //查询数量
    @RequestMapping(value = "datecostNum", method = RequestMethod.GET)
    public ReturnInfo getDatecostNum(@RequestParam(required = false, defaultValue = "") String qsrq,
                                     @RequestParam(required = false, defaultValue = "") String jsrq) {
        List<Map<String, Object>> glf = new ArrayList<>();
        List<Map<String, Object>> jieyou = new ArrayList<>();
        List<Map<String, Object>> xjjy = new ArrayList<>();
        List<Map<String, Object>> xlbz = new ArrayList<>();
        List<Map<String, Object>> maidan = new ArrayList<>();
        List<Map<String, Object>> wxfycn = new ArrayList<>();
        List<Map<String, Object>> wxfycw = new ArrayList<>();
        List<Map<String, Object>> wzfk = new ArrayList<>();
        List<Map<String, Object>> tcf = new ArrayList<>();
        List<Map<String, Object>> zsf = new ArrayList<>();
        List<Map<String, Object>> zxf = new ArrayList<>();
        List<Map<String, Object>> chuanpiao = new ArrayList<>();
        List<Map<String, Object>> sgcl = new ArrayList<>();
        List<Map<String, Object>> peijian = new ArrayList<>();
        List<Map<String, Object>> qtzc = new ArrayList<>();
        List<Map<String, Object>> bgszc = new ArrayList<>();
        List<Map<String, Object>> drjk = new ArrayList<>();
        List<Map<String, Object>> chaoyou = new ArrayList<>();
        List<Map<String, Object>> huihuo = new ArrayList<>();
        List<Map<String, Object>> hhbh = new ArrayList<>();
        List<Map<String, Object>> qtsr = new ArrayList<>();
        List<Map<String, Object>> bgssr = new ArrayList<>();
        List<Map<String, Object>> drhk = new ArrayList<>();
        List<Map<String, Object>> zrye = new ArrayList<>();
        List<Map<String, Object>> drye = new ArrayList<>();
        List<CostInfo> costInfos = getDateCostList(qsrq, jsrq);
        for (CostInfo costInfo : costInfos) {
            try {
                Map<String, Object> map1 = new HashMap<>();
                Map<String, Object> map2 = new HashMap<>();
                Map<String, Object> map3 = new HashMap<>();
                Map<String, Object> map4 = new HashMap<>();
                Map<String, Object> map5 = new HashMap<>();
                Map<String, Object> map6 = new HashMap<>();
                Map<String, Object> map7 = new HashMap<>();
                Map<String, Object> map8 = new HashMap<>();
                Map<String, Object> map9 = new HashMap<>();
                Map<String, Object> map10 = new HashMap<>();
                Map<String, Object> map11 = new HashMap<>();
                Map<String, Object> map13 = new HashMap<>();
                Map<String, Object> map14 = new HashMap<>();
                Map<String, Object> map15 = new HashMap<>();
                Map<String, Object> map16 = new HashMap<>();
                Map<String, Object> map17 = new HashMap<>();
                Map<String, Object> map18 = new HashMap<>();
                Map<String, Object> map19 = new HashMap<>();
                Map<String, Object> map20 = new HashMap<>();
                Map<String, Object> map21 = new HashMap<>();
                Map<String, Object> map22 = new HashMap<>();
                Map<String, Object> map23 = new HashMap<>();
                Map<String, Object> map24 = new HashMap<>();
                Map<String, Object> map25 = new HashMap<>();
                Map<String, Object> map26 = new HashMap<>();

                if (costInfo.getGlf().contains(".")) {
                    int glfInt = Integer.valueOf(costInfo.getGlf().substring(0, costInfo.getGlf().length() - 3)).intValue();
                    map1.put("AREA", costInfo.getBzrq());
                    map1.put("LANDNUM", glfInt);
                } else {
                    int glfInt = Integer.valueOf(costInfo.getGlf()).intValue();
                    map1.put("AREA", costInfo.getBzrq());
                    map1.put("LANDNUM", glfInt);
                }
                if (costInfo.getZcjy().contains(".")) {
                    int jieyouInt = Integer.valueOf(costInfo.getZcjy().substring(0, costInfo.getZcjy().length() - 3)).intValue();
                    map2.put("AREA", costInfo.getBzrq());
                    map2.put("LANDNUM", jieyouInt);
                } else {
                    int jieyouInt = Integer.valueOf(costInfo.getZcjy()).intValue();
                    map2.put("AREA", costInfo.getBzrq());
                    map2.put("LANDNUM", jieyouInt);
                }
                if (costInfo.getXjjy().contains(".")) {
                    int xjjyInt = Integer.valueOf(costInfo.getXjjy().substring(0, costInfo.getXjjy().length() - 3)).intValue();
                    map3.put("AREA", costInfo.getBzrq());
                    map3.put("LANDNUM", xjjyInt);
                } else {
                    int xjjyInt = Integer.valueOf(costInfo.getXjjy()).intValue();
                    map3.put("AREA", costInfo.getBzrq());
                    map3.put("LANDNUM", xjjyInt);
                }
                if (costInfo.getBuzhu().contains("")) {
                    int xlbzInt = Integer.valueOf(costInfo.getBuzhu().substring(0, costInfo.getBuzhu().length() - 3)).intValue();
                    map4.put("AREA", costInfo.getBzrq());
                    map4.put("LANDNUM", xlbzInt);
                } else {
                    int xlbzInt = Integer.valueOf(costInfo.getBuzhu()).intValue();
                    map4.put("AREA", costInfo.getBzrq());
                    map4.put("LANDNUM", xlbzInt);
                }
                if (costInfo.getMaidan().contains("")) {
                    int maidanInt = Integer.valueOf(costInfo.getMaidan().substring(0, costInfo.getMaidan().length() - 3)).intValue();
                    map5.put("AREA", costInfo.getBzrq());
                    map5.put("LANDNUM", maidanInt);
                } else {
                    int maidanInt = Integer.valueOf(costInfo.getMaidan()).intValue();
                    map5.put("AREA", costInfo.getBzrq());
                    map5.put("LANDNUM", maidanInt);
                }
                if (costInfo.getWxfycn().contains(".")) {
                    int wxfycnInt = Integer.valueOf(costInfo.getWxfycn().substring(0, costInfo.getWxfycn().length() - 3)).intValue();
                    map6.put("AREA", costInfo.getBzrq());
                    map6.put("LANDNUM", wxfycnInt);
                } else {
                    int wxfycnInt = Integer.valueOf(costInfo.getWxfycn()).intValue();
                    map6.put("AREA", costInfo.getBzrq());
                    map6.put("LANDNUM", wxfycnInt);
                }
                if (costInfo.getWxfycw().contains(".")) {
                    int wxfycwInt = Integer.valueOf(costInfo.getWxfycw().substring(0, costInfo.getWxfycw().length() - 3)).intValue();
                    map7.put("AREA", costInfo.getBzrq());
                    map7.put("LANDNUM", wxfycwInt);
                } else {
                    int wxfycwInt = Integer.valueOf(costInfo.getWxfycw()).intValue();
                    map7.put("AREA", costInfo.getBzrq());
                    map7.put("LANDNUM", wxfycwInt);
                }
                if (costInfo.getWzfk().contains(".")) {
                    int wzfkInt = Integer.valueOf(costInfo.getWzfk().substring(0, costInfo.getWzfk().length() - 3)).intValue();
                    map8.put("AREA", costInfo.getBzrq());
                    map8.put("LANDNUM", wzfkInt);
                } else {
                    int wzfkInt = Integer.valueOf(costInfo.getWzfk()).intValue();
                    map8.put("AREA", costInfo.getBzrq());
                    map8.put("LANDNUM", wzfkInt);
                }
                if (costInfo.getTcf().contains(".")) {
                    int tcfInt = Integer.valueOf(costInfo.getTcf().substring(0, costInfo.getTcf().length() - 3)).intValue();
                    map9.put("AREA", costInfo.getBzrq());
                    map9.put("LANDNUM", tcfInt);
                } else {
                    int tcfInt = Integer.valueOf(costInfo.getTcf()).intValue();
                    map9.put("AREA", costInfo.getBzrq());
                    map9.put("LANDNUM", tcfInt);
                }
                if (costInfo.getZsf().contains(".")) {
                    int zsfInt = Integer.valueOf(costInfo.getZsf().substring(0, costInfo.getZsf().length() - 3)).intValue();
                    map10.put("AREA", costInfo.getBzrq());
                    map10.put("LANDNUM", zsfInt);
                } else {
                    int zsfInt = Integer.valueOf(costInfo.getZsf()).intValue();
                    map10.put("AREA", costInfo.getBzrq());
                    map10.put("LANDNUM", zsfInt);
                }
                if (costInfo.getZxf().contains(".")) {
                    int zxfInt = Integer.valueOf(costInfo.getZxf().substring(0, costInfo.getZxf().length() - 3)).intValue();
                    map11.put("AREA", costInfo.getBzrq());
                    map11.put("LANDNUM", zxfInt);
                } else {
                    int zxfInt = Integer.valueOf(costInfo.getZxf()).intValue();
                    map11.put("AREA", costInfo.getBzrq());
                    map11.put("LANDNUM", zxfInt);
                }
                if (costInfo.getChuanpiao().contains(".")) {
                    int chuanpiaoInt = Integer.valueOf(costInfo.getChuanpiao().substring(0, costInfo.getChuanpiao().length() - 3)).intValue();
                    map13.put("AREA", costInfo.getBzrq());
                    map13.put("LANDNUM", chuanpiaoInt);
                } else {
                    int chuanpiaoInt = Integer.valueOf(costInfo.getChuanpiao()).intValue();
                    map13.put("AREA", costInfo.getBzrq());
                    map13.put("LANDNUM", chuanpiaoInt);
                }
                if (costInfo.getSgcl().contains(".")) {
                    int sgclInt = Integer.valueOf(costInfo.getSgcl().substring(0, costInfo.getSgcl().length() - 3)).intValue();
                    map14.put("AREA", costInfo.getBzrq());
                    map14.put("LANDNUM", sgclInt);
                } else {
                    int sgclInt = Integer.valueOf(costInfo.getSgcl()).intValue();
                    map14.put("AREA", costInfo.getBzrq());
                    map14.put("LANDNUM", sgclInt);
                }
                if (costInfo.getPeijian().contains(".")) {
                    int peijianInt = Integer.valueOf(costInfo.getPeijian().substring(0, costInfo.getPeijian().length() - 3)).intValue();
                    map15.put("AREA", costInfo.getBzrq());
                    map15.put("LANDNUM", peijianInt);
                } else {
                    int peijianInt = Integer.valueOf(costInfo.getPeijian()).intValue();
                    map15.put("AREA", costInfo.getBzrq());
                    map15.put("LANDNUM", peijianInt);
                }
                if (costInfo.getZcqt().contains(".")) {
                    int qtzcInt = Integer.valueOf(costInfo.getZcqt().substring(0, costInfo.getZcqt().length() - 3)).intValue();
                    map16.put("AREA", costInfo.getBzrq());
                    map16.put("LANDNUM", qtzcInt);
                } else {
                    int qtzcInt = Integer.valueOf(costInfo.getZcqt()).intValue();
                    map16.put("AREA", costInfo.getBzrq());
                    map16.put("LANDNUM", qtzcInt);
                }
                if (costInfo.getBgszc().contains(".")) {
                    int bgszcInt = Integer.valueOf(costInfo.getBgszc().substring(0, costInfo.getZcqt().length() - 3)).intValue();
                    map17.put("AREA", costInfo.getBzrq());
                    map17.put("LANDNUM", bgszcInt);
                } else {
                    int bgszcInt = Integer.valueOf(costInfo.getBgszc()).intValue();
                    map17.put("AREA", costInfo.getBzrq());
                    map17.put("LANDNUM", bgszcInt);
                }
                if (costInfo.getDrjk().contains(".")) {
                    int drjkInt = Integer.valueOf(costInfo.getDrjk().substring(0, costInfo.getSrcy().length() - 3)).intValue();
                    map18.put("AREA", costInfo.getBzrq());
                    map18.put("LANDNUM", drjkInt);
                } else {
                    int drjkInt = Integer.valueOf(costInfo.getDrjk()).intValue();
                    map18.put("AREA", costInfo.getBzrq());
                    map18.put("LANDNUM", drjkInt);
                }
                if (costInfo.getSrcy().contains(".")) {
                    int chaoyouInt = Integer.valueOf(costInfo.getSrcy().substring(0, costInfo.getSrcy().length() - 3)).intValue();
                    map19.put("AREA", costInfo.getBzrq());
                    map19.put("LANDNUM", chaoyouInt);
                } else {
                    int chaoyouInt = Integer.valueOf(costInfo.getSrcy()).intValue();
                    map19.put("AREA", costInfo.getBzrq());
                    map19.put("LANDNUM", chaoyouInt);
                }
                if (costInfo.getHuihuo().contains(".")) {
                    int huihuoInt = Integer.valueOf(costInfo.getHuihuo().substring(0, costInfo.getHuihuo().length() - 3)).intValue();
                    map20.put("AREA", costInfo.getBzrq());
                    map20.put("LANDNUM", huihuoInt);
                } else {
                    int huihuoInt = Integer.valueOf(costInfo.getHuihuo()).intValue();
                    map20.put("AREA", costInfo.getBzrq());
                    map20.put("LANDNUM", huihuoInt);
                }
                if (costInfo.getHhbh().contains(".")) {
                    int hhbhInt = Integer.valueOf(costInfo.getHhbh().substring(0, costInfo.getHhbh().length() - 3)).intValue();
                    map21.put("AREA", costInfo.getBzrq());
                    map21.put("LANDNUM", hhbhInt);
                } else {
                    int hhbhInt = Integer.valueOf(costInfo.getHhbh()).intValue();
                    map21.put("AREA", costInfo.getBzrq());
                    map21.put("LANDNUM", hhbhInt);
                }
                if (costInfo.getSrqt().contains(".")) {
                    int qtsrInt = Integer.valueOf(costInfo.getSrqt().substring(0, costInfo.getHhbh().length() - 3)).intValue();
                    map22.put("AREA", costInfo.getBzrq());
                    map22.put("LANDNUM", qtsrInt);
                } else {
                    int qtsrInt = Integer.valueOf(costInfo.getSrqt()).intValue();
                    map22.put("AREA", costInfo.getBzrq());
                    map22.put("LANDNUM", qtsrInt);
                }
                if (costInfo.getBgssr().contains(".")) {
                    int bgssrInt = Integer.valueOf(costInfo.getBgssr().substring(0, costInfo.getHhbh().length() - 3)).intValue();
                    map23.put("AREA", costInfo.getBzrq());
                    map23.put("LANDNUM", bgssrInt);
                } else {
                    int bgssrInt = Integer.valueOf(costInfo.getBgssr()).intValue();
                    map23.put("AREA", costInfo.getBzrq());
                    map23.put("LANDNUM", bgssrInt);
                }
                if (costInfo.getDrhk().contains(".")) {
                    int drhkInt = Integer.valueOf(costInfo.getDrhk().substring(0, costInfo.getHhbh().length() - 3)).intValue();
                    map24.put("AREA", costInfo.getBzrq());
                    map24.put("LANDNUM", drhkInt);
                } else {
                    int drhkInt = Integer.valueOf(costInfo.getDrhk()).intValue();
                    map24.put("AREA", costInfo.getBzrq());
                    map24.put("LANDNUM", drhkInt);
                }
                if (costInfo.getZrye().contains(".")) {
                    int zryeInt = Integer.valueOf(costInfo.getZrye().substring(0, costInfo.getHhbh().length() - 3)).intValue();
                    map25.put("AREA", costInfo.getBzrq());
                    map25.put("LANDNUM", zryeInt);
                } else {
                    int zryeInt = Integer.valueOf(costInfo.getZrye()).intValue();
                    map25.put("AREA", costInfo.getBzrq());
                    map25.put("LANDNUM", zryeInt);
                }
                if (costInfo.getDrye().contains(".")) {
                    int dryeInt = Integer.valueOf(costInfo.getDrye().substring(0, costInfo.getDrye().length() - 3)).intValue();
                    map26.put("AREA", costInfo.getBzrq());
                    map26.put("LANDNUM", dryeInt);
                } else {
                    int dryeInt = Integer.valueOf(costInfo.getDrye()).intValue();
                    map26.put("AREA", costInfo.getBzrq());
                    map26.put("LANDNUM", dryeInt);
                }
                glf.add(map1);
                jieyou.add(map2);
                xjjy.add(map3);
                xlbz.add(map4);
                maidan.add(map5);
                wxfycn.add(map6);
                wxfycw.add(map7);
                wzfk.add(map8);
                tcf.add(map9);
                zsf.add(map10);
                zxf.add(map11);
                chuanpiao.add(map13);
                sgcl.add(map14);
                peijian.add(map15);
                qtzc.add(map16);
                bgszc.add(map17);
                drjk.add(map18);
                chaoyou.add(map19);
                huihuo.add(map20);
                hhbh.add(map21);
                qtsr.add(map22);
                bgssr.add(map23);
                drhk.add(map24);
                zrye.add(map25);
                drye.add(map26);
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }

        }
        Map<String, Object> lists = new HashMap<>();

        lists.put("glf", glf);
        lists.put("jieyou", jieyou);
        lists.put("xjjy", xjjy);
        lists.put("maidan", maidan);
        lists.put("wxfycn", wxfycn);
        lists.put("wxfycw", wxfycw);
        lists.put("wzfk", wzfk);
        lists.put("chuanpiao", chuanpiao);
        lists.put("sgcl", sgcl);
        lists.put("peijian", peijian);
        lists.put("qtzc", qtzc);
        lists.put("bgszc", bgszc);
        lists.put("drjk", drjk);
        lists.put("chaoyou", chaoyou);
        lists.put("huihuo", huihuo);
        lists.put("hhbh", hhbh);
        lists.put("qtsr", qtsr);
        lists.put("bgssr", bgssr);
        lists.put("drhk", drhk);
        lists.put("zrye", zrye);
        lists.put("drye", drye);
        lists.put("tcf", tcf);
        lists.put("zxf", zxf);
        lists.put("zsf", zsf);
        lists.put("xlbz", zsf);


        return ReturnInfo.info2(lists);
    }

    private static String Add(String a, String b) {
        if (a.equals("")) {
            a = "0";
        }
        if (b.equals("")) {
            b = "0";
        }
        BigDecimal x = new BigDecimal(a);
        BigDecimal y = new BigDecimal(b);
        return x.add(y).toString();
    }

    private static Boolean checkNegative(String jine) {
        Boolean b = false;
        if (jine.matches("^-([1-9]\\d{0,9}|0)(.\\d{1,2})?$")) {
            b = true;
        }
        return b;
    }

    private static String Absolute(String jine) {
        return jine.substring(1, jine.length());
    }
}
